--
-- Author:      name
-- DateTime:    2018-05-05 15:46:35
-- Description: 服务
local skynet = require "skynet"
local queue = require "skynet.queue"
local gameName = 'paohuzi'

local Objects = require "Objects"
local Message = require (gameName..".Message")
local Command = require (gameName..".Command")
local Machine = require (gameName..".Machine")
local Rule 	  = require (gameName..".Rule")

local myqueue = queue()
local param = {...}


local tableid = tonumber(param[1])
local roomid = tonumber(param[2])
local svrid = tonumber(param[3])
g_objects = Objects.new()


local function init()


	local message = Message.new(gameName)	
	local rule = Rule.new()	
	local machine
	local command
	machine = Machine.new(tableid,rule)	
	command = Command.new(message,machine)
	
	g_objects:add(message)
	g_objects:add(rule)
	g_objects:add(machine)
	g_objects:add(command)
	g_objects:hotfix(gameName)
	
	machine:start()
	local f = message:dispatch()
	function _queue( session, source, cmd, ...)		
		local resut = myqueue(f,session, source, cmd, ...)
		return result
	end	
	skynet.dispatch("lua",_queue)

end

---------------------------------------------------------
-- skynet
---------------------------------------------------------
skynet.start(function()
	init()


end)